package com.zenchn.dynamic;

import static com.zenchn.dynamic.TSysAuthorityDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.zenchn.model.TSysAuthority;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TSysAuthorityDynamicMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    BasicColumn[] selectList = BasicColumn.columnList(authId, createTime, authTypeId, authName, iconStyle, authSign, url, target, sorts, parentId, authLevel, oauthClientId, memo);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<TSysAuthority> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<TSysAuthority> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TSysAuthorityResult")
    Optional<TSysAuthority> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TSysAuthorityResult", value = {
        @Result(column="auth_id", property="authId", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="auth_type_id", property="authTypeId", jdbcType=JdbcType.CHAR),
        @Result(column="auth_name", property="authName", jdbcType=JdbcType.VARCHAR),
        @Result(column="icon_style", property="iconStyle", jdbcType=JdbcType.VARCHAR),
        @Result(column="auth_sign", property="authSign", jdbcType=JdbcType.VARCHAR),
        @Result(column="url", property="url", jdbcType=JdbcType.VARCHAR),
        @Result(column="target", property="target", jdbcType=JdbcType.VARCHAR),
        @Result(column="sorts", property="sorts", jdbcType=JdbcType.SMALLINT),
        @Result(column="parent_id", property="parentId", jdbcType=JdbcType.CHAR),
        @Result(column="auth_level", property="authLevel", jdbcType=JdbcType.INTEGER),
        @Result(column="oauth_client_id", property="oauthClientId", jdbcType=JdbcType.CHAR),
        @Result(column="memo", property="memo", jdbcType=JdbcType.VARCHAR)
    })
    List<TSysAuthority> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, TSysAuthority, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, TSysAuthority, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    default int deleteByPrimaryKey(String authId_) {
        return delete(c -> 
            c.where(authId, isEqualTo(authId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    default int insert(TSysAuthority record) {
        return MyBatis3Utils.insert(this::insert, record, TSysAuthority, c ->
            c.map(authId).toProperty("authId")
            .map(createTime).toProperty("createTime")
            .map(authTypeId).toProperty("authTypeId")
            .map(authName).toProperty("authName")
            .map(iconStyle).toProperty("iconStyle")
            .map(authSign).toProperty("authSign")
            .map(url).toProperty("url")
            .map(target).toProperty("target")
            .map(sorts).toProperty("sorts")
            .map(parentId).toProperty("parentId")
            .map(authLevel).toProperty("authLevel")
            .map(oauthClientId).toProperty("oauthClientId")
            .map(memo).toProperty("memo")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    default int insertMultiple(Collection<TSysAuthority> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, TSysAuthority, c ->
            c.map(authId).toProperty("authId")
            .map(createTime).toProperty("createTime")
            .map(authTypeId).toProperty("authTypeId")
            .map(authName).toProperty("authName")
            .map(iconStyle).toProperty("iconStyle")
            .map(authSign).toProperty("authSign")
            .map(url).toProperty("url")
            .map(target).toProperty("target")
            .map(sorts).toProperty("sorts")
            .map(parentId).toProperty("parentId")
            .map(authLevel).toProperty("authLevel")
            .map(oauthClientId).toProperty("oauthClientId")
            .map(memo).toProperty("memo")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    default int insertSelective(TSysAuthority record) {
        return MyBatis3Utils.insert(this::insert, record, TSysAuthority, c ->
            c.map(authId).toPropertyWhenPresent("authId", record::getAuthId)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(authTypeId).toPropertyWhenPresent("authTypeId", record::getAuthTypeId)
            .map(authName).toPropertyWhenPresent("authName", record::getAuthName)
            .map(iconStyle).toPropertyWhenPresent("iconStyle", record::getIconStyle)
            .map(authSign).toPropertyWhenPresent("authSign", record::getAuthSign)
            .map(url).toPropertyWhenPresent("url", record::getUrl)
            .map(target).toPropertyWhenPresent("target", record::getTarget)
            .map(sorts).toPropertyWhenPresent("sorts", record::getSorts)
            .map(parentId).toPropertyWhenPresent("parentId", record::getParentId)
            .map(authLevel).toPropertyWhenPresent("authLevel", record::getAuthLevel)
            .map(oauthClientId).toPropertyWhenPresent("oauthClientId", record::getOauthClientId)
            .map(memo).toPropertyWhenPresent("memo", record::getMemo)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    default Optional<TSysAuthority> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, TSysAuthority, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    default List<TSysAuthority> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, TSysAuthority, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    default List<TSysAuthority> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, TSysAuthority, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    default Optional<TSysAuthority> selectByPrimaryKey(String authId_) {
        return selectOne(c ->
            c.where(authId, isEqualTo(authId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, TSysAuthority, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    static UpdateDSL<UpdateModel> updateAllColumns(TSysAuthority record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(authId).equalTo(record::getAuthId)
                .set(createTime).equalTo(record::getCreateTime)
                .set(authTypeId).equalTo(record::getAuthTypeId)
                .set(authName).equalTo(record::getAuthName)
                .set(iconStyle).equalTo(record::getIconStyle)
                .set(authSign).equalTo(record::getAuthSign)
                .set(url).equalTo(record::getUrl)
                .set(target).equalTo(record::getTarget)
                .set(sorts).equalTo(record::getSorts)
                .set(parentId).equalTo(record::getParentId)
                .set(authLevel).equalTo(record::getAuthLevel)
                .set(oauthClientId).equalTo(record::getOauthClientId)
                .set(memo).equalTo(record::getMemo);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(TSysAuthority record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(authId).equalToWhenPresent(record::getAuthId)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(authTypeId).equalToWhenPresent(record::getAuthTypeId)
                .set(authName).equalToWhenPresent(record::getAuthName)
                .set(iconStyle).equalToWhenPresent(record::getIconStyle)
                .set(authSign).equalToWhenPresent(record::getAuthSign)
                .set(url).equalToWhenPresent(record::getUrl)
                .set(target).equalToWhenPresent(record::getTarget)
                .set(sorts).equalToWhenPresent(record::getSorts)
                .set(parentId).equalToWhenPresent(record::getParentId)
                .set(authLevel).equalToWhenPresent(record::getAuthLevel)
                .set(oauthClientId).equalToWhenPresent(record::getOauthClientId)
                .set(memo).equalToWhenPresent(record::getMemo);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    default int updateByPrimaryKey(TSysAuthority record) {
        return update(c ->
            c.set(createTime).equalTo(record::getCreateTime)
            .set(authTypeId).equalTo(record::getAuthTypeId)
            .set(authName).equalTo(record::getAuthName)
            .set(iconStyle).equalTo(record::getIconStyle)
            .set(authSign).equalTo(record::getAuthSign)
            .set(url).equalTo(record::getUrl)
            .set(target).equalTo(record::getTarget)
            .set(sorts).equalTo(record::getSorts)
            .set(parentId).equalTo(record::getParentId)
            .set(authLevel).equalTo(record::getAuthLevel)
            .set(oauthClientId).equalTo(record::getOauthClientId)
            .set(memo).equalTo(record::getMemo)
            .where(authId, isEqualTo(record::getAuthId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_authority")
    default int updateByPrimaryKeySelective(TSysAuthority record) {
        return update(c ->
            c.set(createTime).equalToWhenPresent(record::getCreateTime)
            .set(authTypeId).equalToWhenPresent(record::getAuthTypeId)
            .set(authName).equalToWhenPresent(record::getAuthName)
            .set(iconStyle).equalToWhenPresent(record::getIconStyle)
            .set(authSign).equalToWhenPresent(record::getAuthSign)
            .set(url).equalToWhenPresent(record::getUrl)
            .set(target).equalToWhenPresent(record::getTarget)
            .set(sorts).equalToWhenPresent(record::getSorts)
            .set(parentId).equalToWhenPresent(record::getParentId)
            .set(authLevel).equalToWhenPresent(record::getAuthLevel)
            .set(oauthClientId).equalToWhenPresent(record::getOauthClientId)
            .set(memo).equalToWhenPresent(record::getMemo)
            .where(authId, isEqualTo(record::getAuthId))
        );
    }
}